<template>
  <div>
    <!-- 购物——购物车页面点击修改颜色，尺寸的组件 -->
    <div class="selection-box">
      <selection @m_close="closeBox" @getColor="getColor" @getSize="getSize" :targetId="clickId"></selection>
      <div class="my-button">
        <button type="button" class="mui-btn mui-btn-warning" @click="updateSelect">确定</button>
      </div>
    </div>
  </div>
</template>

<script>
import selectionBox from "./selectBox.vue";
export default {
  data() {
    return {
      goodsObj: {},
      selectNum: "1",
      originId: this.p_origin_goodsId
    };
  },
  props:["clickId","p_origin_goodsId"],
  methods: {
    // 祖父孙组件传值,但只有点colse时才会有传过来值
    closeBox() {
      this.$emit("p_close");
    },
    getColor(obj){
      this.goodsObj = Object.assign(this.goodsObj,obj)
    },
    getSize(obj){
      this.goodsObj = Object.assign(this.goodsObj,obj)
    },
    // 在购物车页面点击参数修改选择
    updateSelect() {
      var goodsId = this.goodsObj.sid ?
        this.goodsObj.gid + this.goodsObj.cid + this.goodsObj.sid : this.goodsObj.gid + this.goodsObj.cid;
      this.$set(this.goodsObj,"goodsId",goodsId)
      this.$set(this.goodsObj,"originId",this.originId)
      // console.log(this.goodsObj);
      this.$store.commit("updateItemChoice",this.goodsObj);
      this.$emit("p_updateChioce",this.originId);
      this.closeBox();
    }
  },
  components: {
    selection: selectionBox
  }
};
</script>

<style lang="scss" scoped>
$baseColor: #26a2ff;

.selection-box {
  position: fixed;
  bottom: 50px;
  left: 0;
  z-index: 998;
  width: 100%;
  .my-button {
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    position: static;
    bottom: 0;
    left: 0;
    height: 50px;
    line-height: 50px;
    z-index: 666;
    font-size: 18px;
    .mui-btn {
      flex: 50%;
    }
  }
}
</style>
